﻿var a = 0;
var text;
var icon1 = "#fEffect/CharacterEff/1042176/0/0#";
var icon3 = "#fEffect/CharacterEff/1082565/4/0#";
var icon2 = "#fEffect/CharacterEff/1082565/2/0#";
var icon1 = "#fEffect/CharacterEff/1082565/4/0#";
var icon2 = "#fEffect/CharacterEff/1082565/2/0#";
var aaa ="#fUI/UIWindow.img/PvP/Scroll/enabled/next2#";
var icon = "#fUI/UIWindow.img/PvP/Scroll/enabled/next2#";
//"#fUI/Basic.img/BtMin2/normal/0#";
var iconEvent = "#fUI/UIWindow.img/PvP/Scroll/enabled/next2#";
//"#fUI/UIToolTip.img/Item/Equip/Star/Star#";
var icon2 = "#fUI/UIToolTip.img/Item/Equip/Star/Star#";
var aaa = "#fUI/UIWindow/AriantMatch/characterIcon/5#";
var yun = "#fUI/UIWindow/Megaphone/2#"; ////红沙漏
var yun2 = "#fUI/UIWindow/Quest/icon8/0#"; ////蓝指标
var yun8 = "#fUI/UIWindow/MonsterBook/arrowLeft/normal/0#"; ////金左指标
var yun9 = "#fUI/UIWindow/MonsterBook/arrowRight/normal/0#"; ////金右指标
var yun4 = "#fUI/UIWindow/Quest/reward#"; ////奖励
var ttt = "#fUI/UIWindow/Quest/icon2/7#"; //"+ttt+"//美化1
var ttt2 = "#fUI/UIWindow/Quest/icon6/7#"; ////美化2
var ttt3 = "#fUI/UIWindow/Quest/icon3/6#"; //"+ttt3+"//美化圆
var ttt4 = "#fUI/UIWindow/Quest/icon5/1#"; //"+ttt4+"//美化New
var ttt5 = "#fUI/UIWindow/Quest/icon0#"; ////美化!
var ttt7 = "#fUI/Basic/BtHide3/mouseOver/0#"; //"+ttt6+"//美化会员
var ttt6 = "#fUI/UIWindow.img/PvP/Scroll/enabled/next2#";
var epp = "#fEffect/CharacterEff/1082312/0/0#"; //彩光
var eff = "#fCharacter/Weapon/01702523.img/48/straight/0/effect#"; //彩虹带
var eff = "#fEffect/CharacterEff/1112905/0/1#"; //
var epp = "#fEffect/CharacterEff/1082312/0/0#"; //彩光
var epp1 = "#fEffect/CharacterEff/1082312/2/0#"; //彩光1
var axx = "#fEffect/CharacterEff/1051294/0/0#"; //爱心
var xxx = "#fEffect/CharacterEff/1082565/2/0#"; //星系
var ppp = "#fEffect/CharacterEff/1112907/4/0#"; //泡炮 
var epp3 = "#fEffect/CharacterEff/1112908/0/1#"; //彩光3
var axx1 = "#fEffect/CharacterEff/1062114/1/0#"; //爱心
var zs = "#fEffect/CharacterEff/1112946/2/0#"; //砖石粉
var zs1 = "#fEffect/CharacterEff/1112946/1/1#"; //砖石蓝
var dxxx = "#fEffect/CharacterEff/1102232/2/0#"; //星系
var tz = "#fEffect/CharacterEff/1082565/2/0#"; //兔子蓝
var tz1 = "#fEffect/CharacterEff/1082565/4/0#"; //兔子粉
var tz7 = "#fEffect/CharacterEff/1112900/3/1#"; //音符红
var tz8 = "#fEffect/CharacterEff/1112900/4/1#"; //音符绿
var tz88 = "#fEffect/CharacterEff/1112900/5/1#"; //音符绿!
var yun1 = "#fUI/UIWindow/Quest/icon7/10#"; ////红色圆
var tz9 = "#fEffect/CharacterEff/1112902/0/0#"; //蓝心
var tz10 = "#fEffect/CharacterEff/1112903/0/0#"; //红心
var tz11 = "#fEffect/CharacterEff/1112904/0/0#"; //彩心
var tz12 = "#fEffect/CharacterEff/1112924/0/0#"; //黄星
var tz13 = "#fEffect/CharacterEff/1112925/0/0#"; //蓝星
var tz14 = "#fEffect/CharacterEff/1112926/0/0#"; //红星
var tz15 = "#fEffect/CharacterEff/1112949/0/0#"; //花样音符
var tz16 = "#fEffect/CharacterEff/1112949/1/0#"; //花样音符
var tz17 = "#fEffect/CharacterEff/1112949/2/0#"; //花样音符
var tz18 = "#fEffect/CharacterEff/1112949/3/0#"; //花样音符
var tz19 = "#fEffect/CharacterEff/1112949/4/0#"; //花样音符
var tz20 = "#fEffect/CharacterEff/1114000/1/0#"; //红星花
var p3 = "#fUI/UIToolTip.img/Item/Equip/Star/Star#";
var p4 = "#fUI/StarCityUI.img/GradeInfo/icon_ss/7#"
var p1 = "#fUI/SoulUI.img/DungeonMap/icon/soulTrap/0#"
var p = "#fUI/StarCityUI.img/GradeInfo/icon_ss/2#"
var q6 = "#fUI/RunnerGame.img/RunnerGameUI/UI/Point/2#"
var p2 = "#fUI/SoulUI.img/DungeonMap/icon/dungeonItem/0#"
var e2 = "#fUI/Basic.img/HScr7/enabled/base#"
var e1 = "#fUI/Basic.img/HScr7/enabled/next0#"
var e3 = "#fUI/Basic.img/HScr7/enabled/prev0#"
var icon2 = "#fUI/UIToolTip.img/Item/Equip/Star/Star#";
var head = "#fUI/UIWindow2.img/Quest/quest_info/summary_icon/summary#\r\n";
var selects; //记录玩家的选项
var buynum = 0;
var itemlist = Array(
Array(3064261, 400), 
Array(3064260, 300), 
Array(3064251, 200), 
Array(3064250, 100), 
Array(3064282, 200),
Array(3064281, 400), 
Array(3064280, 300), 
Array(3064271, 300), 
Array(3064270, 200), 
Array(3064272, 400), 
Array(3064221, 800), 
Array(3064220, 600), 
Array(3064210, 200), 
Array(3064211, 300), 
Array(3064240, 100), 
Array(3064241, 100), 
Array(3064230, 600), 
Array(3064231, 800), 
Array(3064291, 900), 
Array(3064290, 800), 
Array(3064161, 600), 
Array(3064160, 500), 
Array(3064150, 400), 
Array(3064151, 500), 
Array(3064141, 600),
Array(3064140, 500),
Array(3064181, 300),
Array(3064180, 200),
Array(3064170, 500),
Array(3064171, 600),
Array(3064480, 900),
Array(3064470, 800), 
Array(3064380, 700),
Array(3064370, 600), 
Array(3064310, 900), 
Array(3064311, 1000), 
Array(3064320, 800)

);
var giftId = -1;
var gifts = null;
function start() {
    a = -1;
    action(1, 0, 0);
}

function action(mode, type, selection) {
    if (mode == -1) {
		cm.sendOk("好吧，等你考虑清楚了再来找我。");
        cm.dispose();
    } else {
        if (mode == 1)
            a++;
        else
            a--;
        if (a == -1) {
            cm.dispose();
        } else if (a == 0) {
			text = "  "+"#n#r┄┄┄┅═☆#e"+q6+"<积分兑换星岩>"+q6+"#n☆═┅┄┄┄\r\n\r\n"+""+tz12+""+tz13+""+tz14+""+tz12+""+tz13+""+tz14+""+tz12+""+tz13+""+tz14+""+tz12+""+tz13+""+tz14+""+tz12+""+tz13+""+tz14+""+tz12+""+tz13+""+tz14+""+tz12+"#k#k"+""+"\r\n"+"\r\n\t\t\t尊敬的玩家：【#h0#】\r\n"+"\t[#b我是" + cm.getServerName() + "星岩兑换NPC,请留出一格空间获取装备]\r\n"+"\t\t\t\t你当前的积分为：[#r"+cm.getPlayerPoints()+"#k]点\r\n\r\n"+""+tz12+""+tz13+""+tz14+""+tz12+""+tz13+""+tz14+""+tz12+""+tz13+""+tz14+""+tz12+""+tz13+""+tz14+""+tz12+""+tz13+""+tz14+""+tz12+""+tz13+""+tz14+""+tz12+"#k#k"+" "+"  选择你想要兑换的物品： #b";
			for (var i=0; i<itemlist.length; i++) {
				var extraName = "";
				if (itemlist[i][2]!=null) {
					extraName="("+itemlist[i][2]+")";
				}
				text += "\r\n#r#L" + i + "# 积分 [ " + itemlist[i][1] + " ]　　#b#i" + itemlist[i][0] + "#　　#z" + itemlist[i][0] + "##l#k";
				if (i != 0 && (i+1) % 5 == 0) {
					//text += "\r\n";
				}
			}
            cm.sendSimple(text);
			/*
        } else if (a == 1) {
			selects = selection;
            cm.sendGetNumber("请输入你请你输入想要购买的数量\r\n\r\n#r1个需要" + itemlist[selects][1] + "个#b雪花币#k", 0, 0, 999999);*/
        } else if (a == 1) {
            selects = selection;
			buynum = 1;
            cm.sendYesNo("#e#r你想购买" + buynum + "#e#r个#r#i" + itemlist[selects][0] + "##k#e#r吗？\r\n#e#r你将使用掉" + (buynum * itemlist[selects][1]) + "#e#r积分。");
        } else if (a == 2) {
			var itemid = itemlist[selects][0];
			var itemType = Math.floor(itemid/1000000);
			
			var costPoints = buynum * itemlist[selects][1];
            if (cm.getPlayerPoints()>=costPoints) {
				if (cm.getSpace(itemType)<2) {
					cm.sendOk("#e#r兑换失败，包裹空间不足！");
					cm.dispose();
					return;
				}
                cm.gainPlayerPoints(-costPoints);
				cm.gainItem(itemlist[selects][0], buynum);
				cm.sendOk("#e#r兑换成功了！");
                cm.dispose();
            } else {
                cm.sendOk("#e#r对不起，你没有足够的积分。");
                cm.dispose();
            }
        }
    }//mode
}//f
